package com.xggstudio.crm.ui.mvp.p;

import com.xggstudio.crm.api.APIServer;
import com.xggstudio.crm.base.App;
import com.xggstudio.crm.ui.mvp.m.ReturnVisitBean;
import com.xggstudio.crm.ui.mvp.v.ICallBack;

import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class P_callBack {


    private ICallBack callBack;

    public P_callBack(ICallBack callBack) {
        this.callBack = callBack;
    }


    public void getdata(int page, final int count){
        String token = App.getInstance().getLoginBean().getResult().getAccess_token();

        APIServer.getInstence().getServer()
                .getReturnVisitListData(token,page,count)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<ReturnVisitBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(ReturnVisitBean returnVisitBean) {
                        if(returnVisitBean.getCode().equals("1")){

                            callBack.showData(returnVisitBean);

                        }else{

                        }
                    }
                });
    }


}
